<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'exceptions.php';


class LzSandbox
{
    static public
    function exec($script, $vars = array(), $optional = false)
    {
        if (!is_readable($script))
        {
            if (!$optional)
                throw new LzBadValue($script);
            else
                return false;
        }

        ${'script!'}    = $script;
        ${'vars!'}      = $vars;
        unset($script, $vars, $optional);
        extract(${'vars!'});
        return include ${'script!'};
    }
}
